//$Id: ContextLeader.java,v 1.4 2007/08/30 02:52:08 lilz Exp $
package com.wlcorp.forcazamis.sys.util;

import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

/**
 *  
 ************************************************
 * @file: ContextLeader.java
 * @Copyright: 2007 HundSun Electronics Co.,Ltd.
 * All right reserved.
 ************************************************
 * @package: com.hs.cccecity.sys.utils
 * @class: ContextLeader
 * @description: 
 * 
 * @author: huangjb
 * @since: May 18, 2007-9:19:34 AM
 * @history:
 */
public class ContextLeader extends HttpServlet{

	private static final long serialVersionUID = 1L;

	private WebApplicationContext context;
	
	public void init(ServletConfig config) throws ServletException {
	    super.init(config);
	    try {
		    ServletContext servletContext = config.getServletContext();
		    context = WebApplicationContextUtils
		    	.getRequiredWebApplicationContext(servletContext);
		    
		    ContextUtil.getInstance().setContext(context);
	    } catch (Exception ex) {
	    	ex.printStackTrace();
	    }
	    
	    System.out.print("system contextLearder successfully \n");
	}
	
}
